package com.example.njupt.data;

import com.example.njupt.okhttp.entity.SourceEntity;
import com.example.njupt.views.sticky.StickySection;

import java.util.ArrayList;
import java.util.List;

/**
 * Author:      mwang
 * Create Date: Created in 2021/6/1 16:53
 * Update Date:
 * Modified By:
 * Description:
 */
public class StickyData {
    private SourceEntity entity;
    private List<SourceEntity> entities = new ArrayList<>();
    private StickySection section;
    private List<StickySection> sections = new ArrayList<>();

    private static class StickyDataHolder {
        private static final StickyData instance = new StickyData();
    }

    public static StickyData getInstance() {
        return StickyDataHolder.instance;
    }

    public List<StickySection> productStickySections() {
        sections.clear();
        if (sections.size() == 0) {
            for (int i = 0; i < productHead().size(); i++) {
                sections.add(i, productStickySection(productHead().get(i)));
            }
        }
        return sections;
    }

    private List<String> productHead() {
        List<String> heads = new ArrayList<>();
        heads.add("光学实验");
        heads.add("力学实验");
        heads.add("电学实验");
        heads.add("电子电路实验");
        return heads;
    }

    private StickySection productStickySection(String s) {
        section = new StickySection(true, false, s, productSourceEntities(s));
        return section;
    }

    private List<SourceEntity> productSourceEntities(String s) {
        for (int i = 0; i < 2; i++) {
            entities.add(productSourceEntity(s));
        }
        return entities;
    }

    private SourceEntity productSourceEntity(String s) {
        switch (s) {
            case "光学实验":
                entity = new SourceEntity("等厚干涉", "李永涛",
                        "课程简介：\n通过这个实验可以重点学习如下内容:\n  1.牛顿环的形成原理\n  2.利用牛顿环是如何实现测定凸透镜曲率半径的\n  3.本实验降低系统误差的方法", 1);
                break;
            case "力学实验":
                entity = new SourceEntity("弹性形变", "李兴鳌",
                        "课程简介：\n通过这个实验可以重点学习如下内容:\n  1.牛顿环的形成原理\n  2.利用牛顿环是如何实现测定凸透镜曲率半径的\n  3.本实验降低系统误差的方法", 2);
                break;
            case "电学实验":
                entity = new SourceEntity("电磁感应", "刘立清",
                        "课程简介：\n通过这个实验可以重点学习如下内容:\n  1.牛顿环的形成原理\n  2.利用牛顿环是如何实现测定凸透镜曲率半径的\n  3.本实验降低系统误差的方法", 0);
                break;
            case "电子电路实验":
                entity = new SourceEntity("HB1662芯片", "王正旺",
                        "课程简介：\n通过这个实验可以重点学习如下内容:\n  1.牛顿环的形成原理\n  2.利用牛顿环是如何实现测定凸透镜曲率半径的\n  3.本实验降低系统误差的方法", 1);
                break;
            default:
                break;
        }
        return entity;
    }
}
